package com.settlement.system.service.impl;

import com.settlement.system.mapper.BaseMapper;
import com.settlement.system.mapper.TblOrderAuditReportMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.TblOrderAuditReport;
import com.settlement.system.service.ITblOrderAuditReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 订单稽核报表 服务实现类
 *
 * @author Ximi
 * @since 2020-09-22
 */
@Service
@Slf4j
public class TblOrderAuditReportServiceImpl extends BaseServiceImpl implements ITblOrderAuditReportService {

    @Resource
    private TblOrderAuditReportMapper tblOrderAuditReportMapper;

    @Override
    public BaseMapper init() {
        return tblOrderAuditReportMapper;
    }

    @Override
    public void deleteByTransactionalNo(long transactionalNo) {
        tblOrderAuditReportMapper.deleteByTransactionalNo(transactionalNo);
    }

    @Override
    public TblOrderAuditReport getFoot(Map<String, Object> params) {
        return tblOrderAuditReportMapper.getFoot(params);
    }

    @Override
    public String getSpOrderNo(String[] refBillNoStr) throws ServiceException {
        try {
            return tblOrderAuditReportMapper.getSpOrderNo(refBillNoStr);
        } catch (Exception ex){
            throw new ServiceException("通过优购主订单",ex);
        }
    }

    @Override
    public <ModelType> void save(List<ModelType> list) throws ServiceException {
        try {
            tblOrderAuditReportMapper.batchAdd((List<TblOrderAuditReport>) list);
        } catch (Exception ex) {
            log.error("batch add order audit reports exception:",ex);
            throw new ServiceException("batch add order audit reports exception:",ex);
        }
    }
}

